package com.tm.controller;

import com.tm.service.PayMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tm.pojo.PayPojo;
import tm.pojo.PrivilegePojo;
import tm.pojo.vo.UserBeMemberLogVo;
import tm.result.Result;

import java.util.List;

/**
 * @author Rocky
 * @create 2022-09-28 17:04
 */
@RestController
@RequestMapping("login")
public class PayMemberController {
    @Autowired
    private PayMemberService payMemberService;

    //查询所有会员卡信息
    @PostMapping("queryPrivilege")
    public Result queryPrivilege(){
        return payMemberService.queryPrivilege();
    }

    //用户选择一张卡 然后创建订单
    @PostMapping("payPrivilege")
    public Result payPrivilege(@RequestBody PrivilegePojo privilegePojo){
        return payMemberService.payPrivilege(privilegePojo);
    }

    //支付订单
    @PostMapping("payMember")
    public Result payMember(@RequestBody PayPojo payPojo){
        return payMemberService.payMember(payPojo);
    }

    //用户查看购买记录
    @PostMapping("queryUserBeMemberLog")
    public List<UserBeMemberLogVo> queryUserBeMemberLog(Integer userId){
        return payMemberService.queryUserBeMemberLog(userId);
    }

}
